import axios from 'axios'

const service = axios.create({
  baseURL: process.env.REACT_APP_BASE_URL,
  timeout: 5000,
})

service.interceptors.request.use(function(config) {
  return config
})

service.interceptors.response.use(function(response) {

  if (response.status >= 200 && response.status <= 300) {
    return response.data

  }

  alert('请求错误')
}, function(err) {
  return Promise.reject(err);
})

export default service
